package com.nuotu.datawall.clouddata;

import android.app.Application;
import android.content.Context;
import android.graphics.Color;

import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.util.TextInfo;
import com.nuotu.datawall.clouddata.control.CrashHandler;
import com.nuotu.datawall.clouddata.util.FinalStr;
import com.nuotu.datawall.clouddata.util.LogCook;
import com.nuotu.datawall.clouddata.util.ServerConfig;

import org.xutils.x;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;


public class App  extends Application {

    private static Context mContext;

    @Override
    public void onCreate() {
        super.onCreate();
        mContext=this;
        initXUtil_35();
        initLog();
        CrashHandler.getInstance().init(mContext); //崩溃捕捉
        initDiaLog();
        ServerConfig.initUrl(mContext);
    }

    private void initDiaLog() {
        DialogSettings.DEBUGMODE = true;
        DialogSettings.isUseBlur = true;
        DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
        DialogSettings.theme = DialogSettings.THEME.LIGHT;
        DialogSettings.titleTextInfo=new TextInfo().setFontSize(40);
        DialogSettings.buttonTextInfo=new TextInfo().setFontSize(30);
        DialogSettings.contentTextInfo=new TextInfo().setFontSize(30);
    }

    private void initXUtil_35() {
        x.Ext.init(this);
//      x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.
        x.Ext.setDefaultHostnameVerifier(new HostnameVerifier() {
            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });
    }
    private void initLog() {
        LogCook.getInstance() // 单例获取LogCook实例
                .setLogPath(FinalStr.FILE_PATH_LOG) //设置日志保存路径
                .setLogName("log.txt") //设置日志文件名
                .isOpen(true)  //是否开启输出日志
                .isSave(true)  //是否保存日志
                .initialize(); //完成初始化Crash监听
    }

}
